﻿@model RentHouse.DTO.LoginDTO
@{
    ViewBag.Title = "Login";
}


<div class="header"></div>
<div class="loginWraper">   
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" id="formLogin" autocomplete="off">
    
            <input type="hidden" id="TenantId" name="TenantId" value="" />
            <div class="row cl">
                <label class="form-label col-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-5">
                    <input name="PhoneNum" type="text" placeholder="手机号码" class="input-text size-L" datatype="*2-16" nullmsg="手机不能为空">
                </div>
                <div class="col-4"> </div>
            </div>


            <div class="row cl">
                <label class="form-label col-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-5">
                    <input name="Password" type="password" placeholder="密码" class="input-text size-L" datatype="*2-16" nullmsg="密码不能为空">
                </div>
                <div class="col-4"> </div>
            </div>
            <div class="row cl">
                <div class="formControls col-8 col-offset-3">
                    <input name="VerCode" class="input-text size-L" type="text" placeholder="" style="width:150px;">
                    <img src="/Home/GetVerCode" id="imgVerifyCode"> <a id="btn_ChangeImg" href="javascript:void(0);">看不清，换一张</a>
                </div>

            </div>
            <div class="row">
                <div class="formControls col-8 col-offset-3">
                    <label for="online">
                        <input type="checkbox" name="IsRemeberMe" id="IsRemeberMe" value="true">
                        使我保持登录状态
                    </label>
                </div>
            </div>
            <div class="row">
                <div class="formControls col-8 col-offset-3">
                    <input id="btn_Login" type="button" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
                    <input type="button" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
                </div>
            </div>
        </form>
    </div>
</div>
<div class="footer">掌上组-后台管理</div>

@section footScript
{
    <script>

        //切换验证码
        $("#imgVerifyCode,#btn_ChangeImg").click(function () {

            //重新请求获取验证码的Action
            $("#imgVerifyCode").attr("src", "/Home/GetVerCode?t=" + Math.random());


        });


        //初始化验证插件
        var validform = $("#formLogin").Validform({ tiptype: 2 });

        $("#btn_Login").click(function () {
            //判断客户端是否验证成功，如果成功则向服务端发送ajax请求
            if (validform.check(false)) {

                var formObj = $("#formLogin").serializeArray();

                $.post("/Home/Login", formObj, function (data) {
                    if (data.State == 1) {
                        //成功，跳转到首页
                        var returnUrl ="@Request.QueryString["ReturnUrl"]";
                        if (returnUrl !="") {
                            location.href = returnUrl;
                        } else {
                            location.href = "/Home/Index";
                        }
                    }
                    else {
                        //提示错误信息
                        layer.msg(data.ErrorMessage, { icon: 2, time: 2000 });

                        //更新验证码
                        $("#imgVerifyCode").click();
                    }

                }, "json");
            }

        });




    </script>
}
